home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / 80X86 / DOS32V33.ZIP / EXAMPLES / VESATEST.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-11-21  |  5.1 KB  |  227 lines

  1. comment ~
  2. *****************************************************************************
  3.          Example program for DOS32 dos-extender.
  4.  
  5.    Example on using the VESA BIOS Interface. This program is
  6. uses the VESA.ASM library and takes full advatage of the protected mode
  7. interfacing if available.
  8.  
  9.  
  10.  
  11.  
  12. *****************************************************************************
  13. ~
  14. .386
  15. .MODEL FLAT , C
  16. .STACK
  17.  
  18. include vesa.inc                ; include macros
  19.  
  20.  
  21. VIDEO_MODE_NUMBER = 101h
  22.  
  23.  
  24. ;
  25. ;  Macro to print some text on the screem
  26. ;
  27. Print MACRO string
  28. local @text,@skip
  29.     mov edx,offset @text
  30.     mov ah,9
  31.     int 21h
  32.     jmp @skip
  33. @text db string,13,10,36
  34. @skip:
  35. ENDM
  36.  
  37.  
  38. .DATA
  39. VideoPtr              DD ?
  40. Palette  Label Byte
  41. Include palette.inc
  42. counter               DB  ?
  43. Linear_Mode_Available DB 1
  44. CurrentBank           DB ?
  45.  
  46. .CODE
  47.  
  48.  
  49. public VBEstart
  50.  
  51.  
  52. VBEstart PROC
  53.  
  54.     ; Set video mode for linear memory mapping
  55.     ;
  56.          mov   ax,VIDEO_MODE_NUMBER or 4000h    ; set bit 14 of mode number
  57.          call  CheckVbeMode
  58.          jnc LinearModeisOk
  59.  
  60.     ; if linear memory mapping failed then try ordinary bank switching
  61.     ;
  62.          mov   ax,VIDEO_MODE_NUMBER
  63.          call  CheckVbeMode
  64.          jnc modeisOk
  65.          cmp    dl,1
  66.          je   NoVESA
  67.          cmp    dl,2
  68.          je   @@ModeNotFound
  69.          jmp  ModeNotGood
  70.  
  71. modeisOk:
  72.          Mov   Linear_Mode_Available,0
  73.  
  74. LinearModeisOk:
  75.  
  76.  
  77.         mov   VideoPtr,eax
  78.     ;
  79.     ; Display messages
  80.     ;
  81.         Print 'This is an example program using the VESA driver'
  82.         Print ''
  83.         Print '  -Video mode 640 x 480 at 256 colors found'
  84.         cmp  Linear_Mode_Available,1
  85.         jne  J90
  86.         Print '  -Linear memory mapping is available.'
  87.         jmp  J91
  88. J90:    Print '  -Linear memory mapping not available.'
  89.         mov  ax,4F0Ah
  90.         mov  bl,0
  91.         int 10h
  92.         cmp ax,004Fh
  93.         je J80
  94.         Print <'  Protected mode bank switching not available, using Real Mode'>
  95.         Print <'  bank switching.'>
  96.         jmp J91
  97. J80:
  98.         Print <'  -Using protected mode bank switching'>
  99. J91:
  100.          Print <13,10,'   press any key to display pattern...'>
  101.  
  102.          mov ah,0
  103.          int 16h
  104.  
  105.  
  106.  
  107.  
  108.          call  SetVbeMode       ; set the video mode to previous call to
  109.                                 ; CheckVbeMode
  110.  
  111. ;----------------------------------------------------------------------------
  112. ; The video mode setting up is now complete and the applicaion is ready
  113. ; to start writting to video memory ( address defined in VideoPtr ).
  114. ;----------------------------------------------------------------------------
  115.  
  116.  
  117.  
  118.     ;
  119.     ; Set palette
  120.     ;
  121.          mov    al,0
  122.          mov    dx,3C8h
  123.          out    dx,al
  124.          mov    esi,Offset Palette
  125.          mov    dx,3C9h
  126.          mov    ecx,768
  127.          cld
  128.          rep    outsb
  129.  
  130.  
  131.     ;
  132.     ; Fill in screen with some patterns
  133.     ;
  134.  
  135.          cmp  Linear_Mode_Available,1
  136.          jne  UsingBankSwitching
  137.  
  138.       ;*******************************************
  139.       ; Fill screen using the linear memory map
  140.       ;*******************************************
  141.  
  142.          mov     edi,VideoPtr
  143.          mov     edx, (640*480)/512
  144.          mov     counter,1
  145.          mov     bl,0
  146. Loop01:  mov     ecx,512/4
  147.          mov     al,bl
  148.          mov     ah,bl
  149.          push    ax
  150.          push    ax
  151.          pop     eax
  152.          or      al,0ffh
  153.          rep     stosd
  154.          add     bl,counter
  155.          jnz J99
  156.          sub     bl,counter
  157.          neg     counter
  158. J99:     dec     edx
  159.          jnz Loop01
  160.          jmp  finished
  161.  
  162.       ;*******************************************
  163.       ; Fill screen using bank switching method
  164.       ;*******************************************
  165. UsingBankSwitching:
  166.          mov     CurrentBank,0
  167.          mov     counter,1
  168.          mov     bl,0
  169. loop02:  mov     edi,VideoPtr
  170.          mov     dl,CurrentBank
  171.          SetBank                                ; set bank to DL
  172.          mov     bh,65536/512
  173. Loop03:  mov     ecx,512/4
  174.          mov     al,bl
  175.          mov     ah,bl
  176.          push    ax
  177.          push    ax
  178.          pop     eax
  179.          or al,0ffh
  180.          rep     stosd
  181.          add     bl,counter
  182.          jnz J98
  183.          sub     bl,counter
  184.          neg     counter
  185. J98:     dec     bh
  186.          jnz Loop03
  187.          inc     CurrentBank
  188.          cmp     CurrentBank,5
  189.          jb loop02
  190.  
  191.  
  192. finished:
  193.  
  194.  
  195.         mov    ah,0          ; Wait for key using BIOS call
  196.         int    16h
  197.  
  198.         mov    ax,3          ; Return to TEXT mode
  199.         int    10h
  200.  
  201. Exit:
  202.          Mov    Ax,4C00h    ; Exit this program
  203.          Int    21h
  204.  
  205.  
  206.  
  207. ;------------------------ Error messages ---------------------------------
  208.  
  209. ModeNotGood:
  210.          Print <'VESA BIOS video mode 640x480x256 is incompatible'>
  211.          jmp Exit
  212. @@ModeNotFound:
  213.          Print 'Video mode 640x480x256 not supported  ( VESA mode 101h )'
  214.          jmp Exit
  215.  
  216. NoVESA:
  217.          Print 'VESA BIOS not installed'
  218.          jmp Exit
  219.  
  220. VBEstart ENDP
  221.  
  222.  
  223.  
  224.  
  225.  
  226. End VBEstart
  227.